<script>
	import {
		mapMutations,
		mapState
	} from 'vuex';
	import {
		launch
	} from '@/api/app.js';
	export default {
		onLaunch: function() {
			console.log('App Launch')

			let _self = this
			
			// #ifdef APP-PLUS
			var RTModule = uni.requireNativePlugin("RTModule")
			try {
				RTModule.getSmartCard(function(e) {
					let uuid = null
					if (!e.smartcard || e.smartcard == "null") {
						// 没获取到卡号
						let info = uni.getSystemInfoSync();
						uuid = info.deviceId
					} else {
						uuid = e.smartcard
						uni.showModal({
							title: "卡号",
							content: e.smartcard
						})
					}
					_self.setSmartCard(uuid)
					
					if (uni.getStorageSync("uuid") != uuid) {
						uni.setStorageSync("uuid", uuid)
						launch({
							first: true
						})
					} else {
						launch()
					}
				})
			} catch(e) {
				console.log("错误", e)
			}
			// #endif

			setInterval(function() {
				_self.ping()
			}, 1000 * 10)
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
			this.close()
		},
		methods: {
			...mapMutations(['setSmartCard']),
		}
	}
</script>
<style>
	body {
		background-color: #070707;
		background-image: linear-gradient(0deg, #222222 0%, #010101 51%, #070707 75%);
		color: white;
	}

	/* .page{
		width: 750rpx
		background-color: #070707;
	
		position: absolute;
	} */
</style>
